import React, { useState } from 'react'
import { Navigate } from 'react-router-dom';

export default function Home() {
  const [sum, setSum] = useState(0);

  if (sum === 10) {
    return <Navigate to="/about" />;
  }

  return (
    <div>
      <h2>我是Home组件</h2>
      <h4>当前sum值是: {sum}</h4>
      <button onClick={() => setSum(val => val + 1)}>点击sum值加1</button> <br />
      当sum值是10时，跳转到/about
    </div>

  )
}
